<#include "/java_copyright.include">
<#assign className = table.className>
<#assign classNameLower = className?uncap_first>
package ${basepackage}.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import ${basepackage}.base.*;

import ${basepackage}.dao.${className}Dao;
import ${basepackage}.service.${className}Service;

import ${basepackage}.bean.${className};
import ${basepackage}.bean.${className}Query;
import ${basepackage}.util.MethodUtil;

@Component("${classNameLower}Service")
public class ${className}ServiceImpl implements ${className}Service {
	
	@Autowired
	@Qualifier("${classNameLower}Dao")
	private ${className}Dao ${classNameLower}Dao;

	
	public int countByExample(${className}Query example) {
		return ${classNameLower}Dao.countByExample(example);
	}

	public int deleteByExample(${className}Query example) {
		return ${classNameLower}Dao.deleteByExample(example);
	}

	public int deleteByPrimaryKey(Long id) {
		return ${classNameLower}Dao.deleteByPrimaryKey(id);
	}

	public int insert(${className} record) {
		return ${classNameLower}Dao.insert(record);
	}

	public int insertSelective(${className} record) {
		return ${classNameLower}Dao.insertSelective(record);
	}

	public List<${className}> selectByExample(${className}Query example) {
		return ${classNameLower}Dao.selectByExample(example);
	}

	public ${className} selectByPrimaryKey(Long id) {
		return ${classNameLower}Dao.selectByPrimaryKey(id);
	}

	public PageListResult<${className}> selectPageByExample(${className}Query example) {
		//修改对象中的空字符串为NULL
		MethodUtil.convertEmptyToNull(example);
		//查询分页总条数
		int count = ${classNameLower}Dao.countByExample(example);

		//设置分页信息
		Pagenation page = new Pagenation(example.getPageNo(),example.getPageSize(),count);
		PageListResult<${className}> pageList = PageListResult.newPageListResult();
		pageList.setPagenation(page);

		if(count != 0){
			//查询分面数据
			List<${className}> list = ${classNameLower}Dao.selectPageByExample(example);
			pageList.setValues(list);
		}
		return pageList;
	}

	public int updateByPrimaryKeySelective(${className} record) {
		return ${classNameLower}Dao.updateByPrimaryKeySelective(record);
	}

	public int updateByPrimaryKey(${className} record) {
		return ${classNameLower}Dao.updateByPrimaryKey(record);
	}
}

